Skip to content

Add release pr workflow#1192

Closed
timreimherr wants to merge 2 commits intomasterfrom
timreimherr-add-release-pr-workflow
Closed

Add release pr workflow#1192
timreimherr wants to merge 2 commits intomasterfrom
timreimherr-add-release-pr-workflow

Conversation

@timreimherr
Copy link
Collaborator

This adds a workflow for creating a PR to facilitate the release process.

Copilot AI review requested due to automatic review settings February 25, 2026 21:28
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a GitHub Actions workflow to automate creation of a “release PR” by syncing docs/ and README.md from backup-utils-private into this repo and opening (then auto-merging) a PR for the release branch.

Changes:

  • Add repository_dispatch-triggered workflow Create Release PR.
  • Checkout backup-utils-private, copy docs/ + README.md, commit to release/<version> and push.
  • Create (or find) a PR and enable auto-merge via gh.
Comments suppressed due to low confidence (1)

.github/workflows/create-release-pr.yml:71

  • Same injection risk here: interpolating github.event.client_payload.version directly into the run: script can allow a crafted repository_dispatch payload to execute arbitrary shell commands. Prefer passing it via env: (or parsing $GITHUB_EVENT_PATH) and validating it before constructing branch names / PR metadata.
          version="${{ github.event.client_payload.version }}"
          branch="release/$version"

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

run: |
version="${{ github.event.client_payload.version }}"
branch="release/$version"
pr_number="$(gh pr list --head "$branch" --base master --json number --jq '.[0].number')"
Copy link

Copilot AI Feb 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gh pr list ... --jq '.[0].number' returns null (string) when no PRs are found, not an empty string. With the current -z check, pr_number becomes null and the workflow will skip PR creation and later try to merge a PR numbered null. Update the jq filter / conditional to treat null as empty.

Suggested change
pr_number="$(gh pr list --head "$branch" --base master --json number --jq '.[0].number')"
pr_number="$(gh pr list --head "$branch" --base master --json number --jq '.[0].number // empty')"

Copilot uses AI. Check for mistakes.
Comment on lines +61 to +63
git add docs README.md
git commit --allow-empty -m "$version release"
git push --force-with-lease --set-upstream origin "$branch"
Copy link

Copilot AI Feb 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

git push --force-with-lease can fail on reruns when the remote release/$version branch already exists but hasn’t been fetched into a local origin/release/... tracking ref (common with actions/checkout default fetch-depth: 1). If you intend this workflow to be idempotent, fetch the remote branch first (if it exists) or adjust the push strategy so reruns can update the branch reliably.

Copilot uses AI. Check for mistakes.
uses: actions/checkout@v5
with:
token: ${{ steps.app-token.outputs.token }}
repository: github/backup-utils-private
Copy link

Copilot AI Feb 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The workflow uses ${{ github.repository_owner }} when minting the GitHub App token, but hardcodes repository: github/backup-utils-private for the checkout. Using the same owner variable for the checkout target avoids drift if the repo is ever moved or this workflow is reused elsewhere.

Suggested change
repository: github/backup-utils-private
repository: ${{ github.repository_owner }}/backup-utils-private

Copilot uses AI. Check for mistakes.
Comment on lines +56 to +57
version="${{ github.event.client_payload.version }}"
branch="release/$version"
Copy link

Copilot AI Feb 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

github.event.client_payload.version is interpolated directly into the shell script. If the dispatch payload contains characters like quotes/newlines, this can break out of the assignment and lead to shell injection (and potential secret exfiltration). Pass the value via env: (or read it from $GITHUB_EVENT_PATH with jq) and validate/sanitize it (e.g., enforce a semver/allowed-charset pattern) before using it in git/gh commands.

This issue also appears on line 70 of the same file.

Copilot uses AI. Check for mistakes.
@timreimherr
Copy link
Collaborator Author

Resolved issue via repo configuration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants